import requests
import json
from read_ini import rf
from read_json import oj

class base_req():
    def get_request(self,method,url,data,get_cookies):
        
        base_url=rf.open_ini("server","host")+url
            # 组合成一个完成的url
       
        # return oj.get_json_value(url)
        
        if "http" in base_url:#判断url格式是否正常
            # print(base_url)
            if method=="get":
                res=requests.get(base_url,data,cookies=get_cookies)
            else:
                res=requests.post(base_url,data,cookies=get_cookies)
                # json  text  
            try:
                return res.json()
            except:
                print("是一个文本数据%s",type(res))
            return res.text
        else:
            print("链接地址有误")
        
            
        

req=base_req()
# req.get_request("get","api3/getcourseintro",{"username":"111112"})
        
